package com.myprinciple.singleresponsibility;

/**
 * @author zhupanlin
 * @version 1.0
 * @description: TODO
 * @date 2024/4/9 9:46
 */
public class SingleResponsibility3 {

    public static void main(String[] args) {
        Vehicle2 vehicle2 = new Vehicle2();
        vehicle2.run("汽车");
        vehicle2.runAir("飞机");
        vehicle2.runWater("轮船");
    }
    
}

// 方式3
// 1.这种修改方法没有对原来的类做大修改，只是增加了方法
// 2.这里虽然没有在类级别上遵守单一职责原则，但是在方法级别上遵守单一职责原则
class Vehicle2 {
    public void run(String vehicle){
        System.out.println(vehicle + "在公路上运行");
    }

    public void runAir(String vehicle){
        System.out.println(vehicle + "在天上上运行");
    }

    public void runWater(String vehicle){
        System.out.println(vehicle + "在水中上运行");
    }
}
